package com.jftone.bh.app.util;

import javax.servlet.http.HttpServletRequest;

import org.jftone.util.StringUtil;

public class BrowserUtil {
	
	private static String getUserAgentStr(HttpServletRequest request){
		return request.getHeader("User-Agent").toLowerCase();
	}
	
	public static boolean isIE(HttpServletRequest request) {
		return StringUtil.find(getUserAgentStr(request), "msie");
	}
	
	public static boolean isAndroid(HttpServletRequest request) {
		return StringUtil.find(getUserAgentStr(request), "android");
	}
	
	public static boolean isIOS(HttpServletRequest request) {
		return StringUtil.find(getUserAgentStr(request), "(iphone|ipad|ipod|ios)");
	}
	
	public static boolean isWeixin(HttpServletRequest request) {
		return StringUtil.find(getUserAgentStr(request), "micromessenger");
	}
	
	public static boolean isFirefox(HttpServletRequest request) {
		return StringUtil.find(getUserAgentStr(request), "firefox");
	}
	
	public static boolean isWebkit(HttpServletRequest request) {
		return StringUtil.find(getUserAgentStr(request), "webkit");
	}
	
	public static boolean isOper(HttpServletRequest request) {
		return StringUtil.find(getUserAgentStr(request), "opera");
	}
}
